package br.com.fsa.aplication.Delegate;

import java.util.ArrayList;

import br.com.fsa.aplication.Model.DadoRelatorioVO;
import br.com.fsa.aplication.Model.UsuarioVO;
import br.com.fsa.aplication.Services.LoginSCN;
import br.com.fsa.aplication.Services.RelGrafNotasSCN;
import br.com.fsa.aplication.Services.ServiceDTO;

public class BusinessDelegate {
	private static BusinessDelegate _wsBusiness;

	private BusinessDelegate() throws Exception {

	}

	public synchronized static BusinessDelegate getInstance() throws Exception {
		if (_wsBusiness == null) {
			try {
				return new BusinessDelegate();
			} catch (Exception exception) {
				throw exception;
			}
		} else {
			return _wsBusiness;
		}
	}

	// /METODOS D) LOGIN
	public ServiceDTO validaLogin(ServiceDTO _dto) throws Exception {
		ServiceDTO _response = new ServiceDTO();
		try {
			if (_dto.existe("loginC")) {
				LoginSCN SCN = new LoginSCN();
				boolean volta = SCN.executaLogin((UsuarioVO)_dto.get("loginC") );
				_response.set("resposta", volta);
			}
		} catch (Exception e) {
			throw e;
		}
		return _response;

	}
	
	public ServiceDTO getDadosGraf(ServiceDTO _dto) throws Exception {
		ServiceDTO _response = new ServiceDTO();
		try {
			if (_dto.existe("tipo") && _dto.existe("ano") ) {
				RelGrafNotasSCN grafSCN = new RelGrafNotasSCN();
				
				ArrayList<DadoRelatorioVO> volta =   (ArrayList<DadoRelatorioVO>)grafSCN.getDados( _dto).get("retorno");
				_response.set("resposta", volta);
			}
		} catch (Exception e) {
			throw e;
		}
		return _response;

	}
	
	

}
